<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>LTO Testing (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="LTO Testing (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="LTO Testing (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Testsuites.html" rel="up" title="Testsuites">
<link href="gcov-Testing.html" rel="next" title="gcov Testing">
<link href="C-Tests.html" rel="prev" title="C Tests">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="LTO-Testing">
<div class="nav-panel">
<p>
Next: <a href="gcov-Testing.html" accesskey="n" rel="next">Support for testing <code class="command">gcov</code></a>, Previous: <a href="C-Tests.html" accesskey="p" rel="prev">C Language Testsuites</a>, Up: <a href="Testsuites.html" accesskey="u" rel="up">Testsuites</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Support-for-testing-link_002dtime-optimizations"><span>7.5 Support for testing link-time optimizations<a class="copiable-link" href="#Support-for-testing-link_002dtime-optimizations"> &para;</a></span></h3>

<p>Tests for link-time optimizations usually require multiple source files
that are compiled separately, perhaps with different sets of options.
There are several special-purpose test directives used for these tests.
</p>
<dl class="table">
<dt><code class="code">{ dg-lto-do <var class="var">do-what-keyword</var> }</code></dt>
<dd><p><var class="var">do-what-keyword</var> specifies how the test is compiled and whether
it is executed.  It is one of:
</p>
<dl class="table">
<dt><code class="code">assemble</code></dt>
<dd><p>Compile with <samp class="option">-c</samp> to produce a relocatable object file.
</p></dd>
<dt><code class="code">link</code></dt>
<dd><p>Compile, assemble, and link to produce an executable file.
</p></dd>
<dt><code class="code">run</code></dt>
<dd><p>Produce and run an executable file, which is expected to return
an exit code of 0.
</p></dd>
</dl>

<p>The default is <code class="code">assemble</code>.  That can be overridden for a set of
tests by redefining <code class="code">dg-do-what-default</code> within the <code class="code">.exp</code>
file for those tests.
</p>
<p>Unlike <code class="code">dg-do</code>, <code class="code">dg-lto-do</code> does not support an optional
&lsquo;<samp class="samp">target</samp>&rsquo; or &lsquo;<samp class="samp">xfail</samp>&rsquo; list.  Use <code class="code">dg-skip-if</code>,
<code class="code">dg-xfail-if</code>, or <code class="code">dg-xfail-run-if</code>.
</p>
</dd>
<dt><code class="code">{ dg-lto-options { { <var class="var">options</var> } [{ <var class="var">options</var> }] } [{ target <var class="var">selector</var> }]}</code></dt>
<dd><p>This directive provides a list of one or more sets of compiler options
to override <var class="var">LTO_OPTIONS</var>.  Each test will be compiled and run with
each of these sets of options.
</p>
</dd>
<dt><code class="code">{ dg-extra-ld-options <var class="var">options</var> [{ target <var class="var">selector</var> }]}</code></dt>
<dd><p>This directive adds <var class="var">options</var> to the linker options used.
</p>
</dd>
<dt><code class="code">{ dg-suppress-ld-options <var class="var">options</var> [{ target <var class="var">selector</var> }]}</code></dt>
<dd><p>This directive removes <var class="var">options</var> from the set of linker options used.
</p></dd>
</dl>

</div>



</body>
</html>
